var express = require('express');
var router = express.Router();
const { secretKey } = require('../utils/token');
const jwt = require("jsonwebtoken");
/* GET home page. */
router.get('/', function (req, res, next) {
  res.render('index', { title: 'Express' });
});
router.get('/getToken', function (req, res) {
  //获取到客户端发送过来的token
  const token = req.get('Authorization');
  //将编码后的token再转换回来
  const decode = jwt.verify(token.split(" ")[1], secretKey);
  res.send(decode);
})
module.exports = router;

